Public Class ExitButton

    Private Sub ExitButton_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Redraw()
    End Sub
    Public Sub Redraw()
        Dim bmp As New Bitmap(Me.Width, Me.Height)
        Dim g As Graphics = Graphics.FromImage(bmp)
        g.FillRectangle(Brushes.LightGray, New Rectangle(0, 0, bmp.Width, bmp.Height))
        Dim path As New Drawing2D.GraphicsPath()
        path.AddArc(New Rectangle(0, 0, 10, 10), 180, 90)
        path.AddLine(5, 0, 15, 0)
        path.AddArc(New Rectangle(9, 0, 10, 10), 270, 90)
        path.AddLine(20, 5, 20, 15)
        path.AddArc(New Rectangle(9, 9, 10, 10), 0, 90)
        path.AddLine(15, 20, 5, 20)
        path.AddArc(New Rectangle(0, 9, 10, 10), 90, 90)
        path.AddLine(0, 15, 0, 5)

        Dim Back As New Drawing2D.PathGradientBrush(path)

        Dim clr As New Drawing2D.ColorBlend
        clr.Colors = New Color() {Color.Red, Color.Red, Color.Salmon}
        clr.Positions = New Single() {0.0, 0.8, 1.0}
        Back.InterpolationColors = clr
        Back.CenterPoint = New Point(10, 10)
        g.FillRectangle(Back, New Rectangle(0, 0, Me.Width, Me.Height))
        Dim p1 As New Pen(Color.Snow)
        p1.Width = 3
        Dim p2 As New Pen(Color.Black)
        p2.Width = 3
        g.DrawLine(p1, 4, 4, 14, 14)
        g.DrawLine(p1, 4, 14, 14, 4)

        g.DrawLine(p1, 5, 5, 15, 15)
        g.DrawLine(p1, 5, 15, 15, 5)
        'Dim overlay As New Drawing2D.LinearGradientBrush(New Rectangle(5, 5, Me.Width, Me.Height / 2), Color.FromArgb(75, Color.LightGray), Color.FromArgb(100, Color.LightGray), Drawing2D.LinearGradientMode.Vertical)
        'g.FillRectangle(overlay, New Rectangle(5, 5, Me.Width, Me.Height / 2))
        bmp.MakeTransparent(Color.LightGray)
        Me.BackgroundImage = bmp

    End Sub
    Public Sub DrawHover()
        Dim bmp As New Bitmap(Me.Width, Me.Height)
        Dim g As Graphics = Graphics.FromImage(bmp)
        For x = 0 To Me.Width - 1
            For y = 0 To Me.Height - 1
                bmp.SetPixel(x, y, Color.LightGray)
            Next
        Next
        Dim path As New Drawing2D.GraphicsPath()
        path.AddArc(New Rectangle(0, 0, 10, 10), 180, 90)
        path.AddLine(5, 0, 15, 0)
        path.AddArc(New Rectangle(9, 0, 10, 10), 270, 90)
        path.AddLine(20, 5, 20, 15)
        path.AddArc(New Rectangle(9, 9, 10, 10), 0, 90)
        path.AddLine(15, 20, 5, 20)
        path.AddArc(New Rectangle(0, 9, 10, 10), 90, 90)
        path.AddLine(0, 15, 0, 5)

        Dim Back As New Drawing2D.PathGradientBrush(path)
        Dim clr As New Drawing2D.ColorBlend
        clr.Colors = New Color() {Color.Salmon, Color.Red, Color.Red}
        clr.Positions = New Single() {0.0, 0.8, 1.0}
        Back.InterpolationColors = clr
        Back.CenterPoint = New Point(10, 10)
        g.FillRectangle(Back, New Rectangle(0, 0, Me.Width, Me.Height))
        Dim p1 As New Pen(Color.Snow)
        p1.Width = 3
        Dim p2 As New Pen(Color.Black)
        p2.Width = 3
        g.DrawLine(p1, 4, 4, 14, 14)
        g.DrawLine(p1, 4, 14, 14, 4)

        g.DrawLine(p1, 5, 5, 15, 15)
        g.DrawLine(p1, 5, 15, 15, 5)
        'Dim overlay As New Drawing2D.LinearGradientBrush(New Rectangle(5, 5, Me.Width - 5, Me.Height / 2 - 5), Color.FromArgb(75, Color.LightGray), Color.FromArgb(150, Color.LightGray), Drawing2D.LinearGradientMode.Vertical)
        'g.FillRectangle(overlay, New Rectangle(5, 5, Me.Width - 5, Me.Height / 2 - 5))
        bmp.MakeTransparent(Color.LightGray)
        Me.BackgroundImage = bmp

    End Sub
    Public Sub DrawSelected()
        Dim bmp As New Bitmap(Me.Width, Me.Height)
        Dim g As Graphics = Graphics.FromImage(bmp)
        For x = 0 To Me.Width - 1
            For y = 0 To Me.Height - 1
                bmp.SetPixel(x, y, Color.LightGray)
            Next
        Next
        Dim path As New Drawing2D.GraphicsPath()
        path.AddArc(New Rectangle(0, 0, 10, 10), 180, 90)
        path.AddLine(5, 0, 15, 0)
        path.AddArc(New Rectangle(9, 0, 10, 10), 270, 90)
        path.AddLine(20, 5, 20, 15)
        path.AddArc(New Rectangle(9, 9, 10, 10), 0, 90)
        path.AddLine(15, 20, 5, 20)
        path.AddArc(New Rectangle(0, 9, 10, 10), 90, 90)
        path.AddLine(0, 15, 0, 5)

        Dim Back As New Drawing2D.PathGradientBrush(path)

        Dim clr As New Drawing2D.ColorBlend
        clr.Colors = New Color() {Color.Red, Color.DarkRed, Color.Black}
        clr.Positions = New Single() {0.0, 0.8, 1.0}

        Back.InterpolationColors = clr
        Back.CenterPoint = New Point(10, 10)
        g.FillRectangle(Back, New Rectangle(0, 0, Me.Width, Me.Height))
        Dim p1 As New Pen(Color.Snow)
        p1.Width = 3
        Dim p2 As New Pen(Color.Black)
        p2.Width = 3
        g.DrawLine(p1, 4, 4, 14, 14)
        g.DrawLine(p1, 4, 14, 14, 4)

        g.DrawLine(p1, 5, 5, 15, 15)
        g.DrawLine(p1, 5, 15, 15, 5)
        'Dim overlay As New Drawing2D.LinearGradientBrush(New Rectangle(0, 0, Me.Width, Me.Height / 2), Color.FromArgb(75, Color.LightGray), Color.FromArgb(100, Color.LightGray), Drawing2D.LinearGradientMode.Vertical)
        'g.FillRectangle(overlay, New Rectangle(0, 0, Me.Width, Me.Height / 2))
        bmp.MakeTransparent(Color.LightGray)
        Me.BackgroundImage = bmp
    End Sub

    Private Sub ExitButton_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        DrawSelected()
    End Sub

    Private Sub ExitButton_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        DrawSelected()
    End Sub

    Private Sub ExitButton_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
        DrawHover()
    End Sub

    Private Sub ExitButton_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
        Redraw()
    End Sub
End Class
